<template>
  <div id="app">
    <router-view />
  </div>
</template>

<script>
import warterMark from '@/utils/warterMark.js'
import { mapGetters } from 'vuex'
export default {
  name: 'App',
  data() {
    return {
      form: {
        name: '张三'
      }
    }
  },
  computed: {
    ...mapGetters(['userInfo'])
  },
  watch: {
    userInfo: {
      immediate: true,
      deep: true,
      handler(val) {
        if (val) {
          warterMark.set(this.userInfo.userName + this.addDate())
        } else {
          warterMark.set('')
        }
      }
    },
    $route: {
      deep: true,
      handler(route) {
        // 非列表页面不显示水印
        route.meta.footerHidden && warterMark.set('')
      }
    }
  },
  methods: {
    addDate() {
      const nowDate = new Date()
      const date = {
        year: nowDate.getFullYear(),
        month: nowDate.getMonth() + 1,
        date: nowDate.getDate()
      }
      const systemDate = date.year + '-' + date.month + '-' + date.date
      return systemDate
    }
  }
}
</script>
